﻿@page "/"

<h1>RenderFragment Example</h1>

<h3>Pets</h3>

<TableTemplate Items="pets" Context="pet">
    <TableHeader>
        <th>ID</th>
        <th>Name</th>
    </TableHeader>
    <RowTemplate>
        <td>@pet.PetId</td>
        <td>@pet.Name</td>
    </RowTemplate>
</TableTemplate>

<h3>People</h3>

<TableTemplate Items="people" Context="person">
    <TableHeader>
        <th>First</th>
        <th>Last</th>
        <th>Handle</th>
    </TableHeader>
    <RowTemplate>
        <td>@person.FirstName</td>
        <td>@person.LastName</td>
        <td>@person.TwitterHandle</td>
    </RowTemplate>
</TableTemplate>

@code {
    private List<Pet> pets = new()
    {
        new Pet { PetId = 2, Name = "Mr. Bigglesworth" },
        new Pet { PetId = 4, Name = "Salem Saberhagen" },
        new Pet { PetId = 7, Name = "K-9" }
    };

    private List<Person> people = new()
    {
        new Person { FirstName = "Mark", LastName = "Otto", TwitterHandle = "@mdo" },
        new Person { FirstName = "Jacob", LastName = "Thornton", TwitterHandle = "@jac" },
        new Person { FirstName = "Larry the bird",  TwitterHandle = "@twitter" },
    };

    private class Pet
    {
        public int PetId { get; set; }
        public string Name { get; set; }
    }

    private class Person
    {
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public string TwitterHandle { get; set; }
    }
}